// Logistics/WarehouseEntry/WarehouseEntry.js
/*{
单元名称：入库页面js
单元功能：通过运单号获取运单信息显示，获取运输点信息，上传入库状态
所属模块功能：
创建人：yan
创建时间：230831
修改人：
修改时间：
}*/
let logisticsBehavior = require('../behavior/logistics')
Page({
  behaviors: [logisticsBehavior],

  /**
   * 页面的初始数据
   */
  data: {
    orderid: '',

    inputData: {
      //节点
      jiedian: '到达入库',
    }

  },
  components: {

  },
  // 记录验证表单项
  validIpt(e) {

    let { validObj, } = this.data
    this.data.validObj = {
      ...validObj,
      ...e.detail,
    };
  },
  //验证数据
  validForm(validObj){
    return new Promise((resolve, reject) => {
      let valid = Object.values(validObj).includes(false) ? false : true;
      resolve(valid)
    })
  },

  bindChange(e){
    let detail = e.detail,
      field = detail.field,
      id = field.field_id || field.fieldName,
      type = field.type,
      val = detail.val,
      val2 = '',
      obj = this.data.inputData;

    if (type === 'num' || type === 'currency' || type === 'percent'){
      val = val ? val : null
    }

    //赋值
    this.data.inputData[id] = val;
    this.data.defData[id] = val;

  },

  //获取订单信息
  getOrder(){
    wx.showLoading({mask:true});
    setTimeout(() => {
      wx.hideLoading();
      this.setData({
        waybill: {
          order_status: '已发货',
          order_no: this.data.orderid,
          order_time: '2023-05-11',
          section: '南庄-福州',
          name: '广告品',
          num: '5',
          pack: '纸箱',
          car_num: '鸿景提供运力'
        }
      });
    },500)
  },

  //保存
  /*onConfirmPoint(e){
    let {info} = e.detail,
      url = `WLAuth/GenZongJiLu`,
      {orderid } = this.data,
      post = {
        "yundan": orderid,
        ...info
      };
    wx.$post(5,url,post).then(res => {
      if (res.errcode != 0) return;

    })
  },*/


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let {orderid} = options;
    this.setData({orderid,});
    this.ready();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },


  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})
